/*
 * @FileName: [MenuController.java]
 * 
 * @Package controller
 * 
 * 
 * Copyright (c) 2011-2015 BCINFO Technology Limited Com. All rights reserved.
 * 
 * This software is the confidential and proprietary information of BCINFO Technology Limited Company ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the contract agreement you entered into with RKY.
 * 
 * $Rev: 1079 $ $LastChangedDate: 2013-10-12 10:19:36 +0800 (周六, 2013-10-12) $ $LastChangedBy: lengzq $
 * 
 * @category bcinfo-upp
 * 
 * @version 1.1
 * 
 * @author $Author: lengzq $
 * 
 * Change History:[Formatter: author date description] <br/> 1 2 3
 */

package com.bci.pwtz.controller;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bci.pwtz.common.PwtzConstants;
import com.bci.pwtz.common.util.MutiPatternParser;
import com.bci.pwtz.common.util.PaginationList;
import com.bci.pwtz.exception.PwtzException;
import com.bci.pwtz.mysql.model.CompanyMenu;
import com.bci.pwtz.service.CompanyMenuService;



/**
 * 用户控制器controller <br/>
 * <p>
 * Description:<br/>
 * <p>
 * 包含以下功能 <br/>
 * 登陆 <br/>
 * 
 * <PRE>
 *      /user/${actionName}
 * </PRE>
 * <p>
 */
@Controller
@RequestMapping("/user/menu")
public class CompanyMenuController extends AbstractController
{
    @Autowired
    private CompanyMenuService     companyMenuService;

    /**
     * 
     * 执行登录操作(异步请求) <br/>
     * <p>
     * Description: 执行登录操作,登录成功后记录用户信息到session <br/>
     * <p>
     * Author: huangb<br/>
     * <p>
     * Date: 2014-9-12-下午4:09:11<br/>
     * <p>
     * 
     * @param session
     * @param tel
     * @param pwd
     * @param imageCode
     * @return
     * 
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> list(int pid)
    {
//        System.out.println("PwtzConstants.mutiPatternParserMap="+PwtzConstants.mutiPatternParserMap);
        Iterator it = PwtzConstants.mutiPatternParserMap.keySet().iterator();
        while(it.hasNext()){
            Short key = (Short) it.next();
//            System.out.println("key="+key);
            MutiPatternParser value = (MutiPatternParser) PwtzConstants.mutiPatternParserMap.get(key);
//            System.out.println(value.toString());
        }
        Map<String, Object> map = new HashMap<String, Object>();
        PaginationList<CompanyMenu> list = null;
        try
        {
            list = (PaginationList<CompanyMenu>) companyMenuService.findMenuInfo(pid, getPageSize(),getPage());
            if (list != null)
            {
                map.put("rows", list.getRecords());
                map.put("total", list.getTotalRecord());
            }
        }
        catch (PwtzException e)
        {
            map.put("total", 0);
            handleException(e);
        }
        catch (Exception e)
        {
            map.put("total", 0);
            handleException(e);
        }

        return map;
    }
 
}